# Importing Data
NIGERIA<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "g1:g325")

# Checking the Imported Data
View(NIGERIA)
# Creating Time Series Data
NIGERIA_ts <- ts(NIGERIA, start=c(1991,1), end=c(2014,12), frequency=12)
# Viewing and Checking the Created Time Series Data
NIGERIA_ts
sum(is.na(NIGERIA_ts))
library(forecast)
NIGERIA_ts <- tsclean(NIGERIA_ts)
NIGERIA_ts

# Identification: Plotting the Time Series Data
plot(NIGERIA_ts)

# Estimating the appropriate model
NIGERIA_ts_model <- auto.arima(NIGERIA_ts)
NIGERIA_ts_model

# Forecasting
options(max.print=1000000)
NIGERIA_ts_forecast <- forecast (NIGERIA_ts_model, level=c(95), h=312)
plot(NIGERIA_ts_forecast)
NIGERIA_ts_forecast             

# Exporting
write.table(NIGERIA_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/NIGERIA_TSA.csv", sep=",")


